home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / ppc-amigaos / include / powerpc / powerpc.h < prev    next >
C/C++ Source or Header  |  2000-02-28  |  10KB  |  285 lines

  1. #ifndef POWERPC_POWERPC_H
  2. #define POWERPC_POWERPC_H
  3.  
  4. #ifndef EXEC_TYPES_H
  5. #include <exec/types.h>
  6. #endif
  7.  
  8. #ifndef EXEC_LIBRARIES_H
  9. #include <exec/libraries.h>
  10. #endif
  11.  
  12. #define POWERPCNAME "powerpc.library"
  13.  
  14. struct PPCBase {
  15.     struct Library PPC_LibNode;
  16.     APTR PPC_SysLib;
  17.     APTR PPC_DosLib;
  18.     APTR PPC_SegList;
  19.     APTR PPC_NearBase;
  20.     UBYTE PPC_Flags;
  21.     UBYTE PPC_DosVer;
  22. };
  23.  
  24. /* tagitem values for GetHALInfo (V14+) */
  25.  
  26. #define HINFO_TAGS            (TAG_USER+0x103000)
  27. #define HINFO_ALEXC_HIGH      (HINFO_TAGS+0)     /* High word of emulated
  28.                             alignment exceptions */
  29. #define HINFO_ALEXC_LOW       (HINFO_TAGS+1)     /* Low word of ... */
  30.  
  31. /* tagitem values for SetScheduling (V14+) */
  32.  
  33. #define SCHED_TAGS            (TAG_USER+0x104000)
  34. #define SCHED_REACTION        (SCHED_TAGS+0)     /* reaction of low activity tasks */
  35.  
  36. /* tagitem values for GetInfo */
  37.  
  38. #define GETINFO_TAGS    (TAG_USER+0x102000)
  39. #define GETINFO_CPU     (GETINFO_TAGS+0)   /* CPU type (see below) */
  40. #define GETINFO_PVR     (GETINFO_TAGS+1)   /* PVR type (see below) */
  41. #define GETINFO_ICACHE  (GETINFO_TAGS+2)   /* Instruction cache state */
  42. #define GETINFO_DCACHE  (GETINFO_TAGS+3)   /* Data cache state */
  43. #define GETINFO_PAGETABLE (GETINFO_TAGS+4)   /* Page table location */
  44. #define GETINFO_TABLESIZE (GETINFO_TAGS+5)   /* Page table size */
  45. #define GETINFO_BUSCLOCK (GETINFO_TAGS+6)   /* PPC bus clock */
  46. #define GETINFO_CPUCLOCK (GETINFO_TAGS+7)   /* PPC CPU clock */
  47. #define GETINFO_CPULOAD (GETINFO_TAGS+8)   /* Total CPU usage */
  48. #define GETINFO_SYSTEMLOAD (GETINFO_TAGS+9) /* Total system usage */
  49.  
  50.  
  51. /* PPCINFO_ICACHE / PPCINFO_DCACHE */
  52.  
  53. #define CACHEB_ON_UNLOCKED      0
  54. #define CACHEB_ON_LOCKED        1
  55. #define CACHEB_OFF_UNLOCKED     2
  56. #define CACHEB_OFF_LOCKED       3
  57.  
  58. #define CACHEF_ON_UNLOCKED      (1L<<0)
  59. #define CACHEF_ON_LOCKED        (1L<<1)
  60. #define CACHEF_OFF_UNLOCKED     (1L<<2)
  61. #define CACHEF_OFF_LOCKED       (1L<<3)
  62.  
  63.  
  64. #define CPUB_603   4
  65. #define CPUB_603E  8
  66. #define CPUB_604   12
  67. #define CPUB_604E  16
  68. #define CPUB_620   20
  69.  
  70. #define CPUF_603  (1L<<4)
  71. #define CPUF_603E (1L<<8)
  72. #define CPUF_604  (1L<<12)
  73. #define CPUF_604E (1L<<16)
  74. #define CPUF_620  (1L<<20)
  75.  
  76. struct PPCArgs {
  77.     APTR  PP_Code;          /* Code Entry / Basevariable (OS Callback) */
  78.     LONG  PP_Offset;        /* Offset into Library-Jumptable (OS Callback) */
  79.     ULONG PP_Flags;         /* see below */
  80.     APTR  PP_Stack;         /* Pointer to first argument to be copied or NULL */
  81.     ULONG PP_StackSize;     /* Size of stack area to be copied or 0 */
  82.     ULONG PP_Regs[15];      /* Registervalues to be transferred */
  83.     DOUBLE PP_FRegs[8];     /* FPU Registervalues to be transferred */
  84. };
  85.  
  86. /* PP_Flags */
  87.  
  88. #define PPF_ASYNC   (1L<<0) /* call PPC/68K asynchron */
  89. #define PPF_LINEAR  (1L<<1) /* pass r3-r10/f1-f8 (V15+) */
  90. #define PPF_THROW   (1L<<2) /* throw exception before entering function */
  91.  
  92. /* status returned by RunPPC, WaitForPPC, Run68K and WaitFor68K */
  93.  
  94. #define PPERR_SUCCESS  0 /* success */
  95. #define PPERR_ASYNCERR 1 /* synchron call after asynchron call */
  96. #define PPERR_WAITERR  2 /* WaitFor[PPC/68K] after synchron call */
  97.  
  98. /* Offsets into the RegisterArrays.for 68K Callbacks */
  99. #define PPREG_D0 0
  100. #define PPREG_D1 1
  101. #define PPREG_D2 2
  102. #define PPREG_D3 3
  103. #define PPREG_D4 4
  104. #define PPREG_D5 5
  105. #define PPREG_D6 6
  106. #define PPREG_D7 7
  107.  
  108. #define PPREG_A0 8
  109. #define PPREG_A1 9
  110. #define PPREG_A2 10
  111. #define PPREG_A3 11
  112. #define PPREG_A4 12
  113. #define PPREG_A5 13
  114. #define PPREG_A6 14
  115.  
  116. #define PPREG_FP0 0
  117. #define PPREG_FP1 1
  118. #define PPREG_FP2 2
  119. #define PPREG_FP3 3
  120. #define PPREG_FP4 4
  121. #define PPREG_FP5 5
  122. #define PPREG_FP6 6
  123. #define PPREG_FP7 7
  124.  
  125. #ifndef POWERPCLIB_V7 /* use max. version 7 of powerpc.library -> */
  126.               /* ppc.library can be used instead of WarpKernal */
  127.               /* V7 is recommended for "simple" applications */
  128.  
  129. /* Cache flags (required by SetCache/SetCache68K) */
  130.  
  131. #define CACHE_DCACHEOFF    1
  132. #define CACHE_DCACHEON     2
  133. #define CACHE_DCACHELOCK   3
  134. #define CACHE_DCACHEUNLOCK 4
  135. #define CACHE_DCACHEFLUSH  5
  136. #define CACHE_ICACHEOFF    6
  137. #define CACHE_ICACHEON     7
  138. #define CACHE_ICACHELOCK   8
  139. #define CACHE_ICACHEUNLOCK 9
  140. #define CACHE_ICACHEINV    10
  141. #define CACHE_DCACHEINV    11
  142.  
  143. /* Hardware flags (required by SetHardware) */
  144.  
  145. #define HW_TRACEON              1             /* enable singlestep mode */
  146. #define HW_TRACEOFF             2             /* disable singlestep mode */
  147. #define HW_BRANCHTRACEON        3             /* enable branch trace mode */
  148. #define HW_BRANCHTRACEOFF       4             /* disable branch trace mode */
  149. #define HW_FPEXCON              5             /* enable FP exceptions */
  150. #define HW_FPEXCOFF             6             /* disable FP exceptions */
  151. #define HW_SETIBREAK            7             /* set instruction breakpoint */
  152. #define HW_CLEARIBREAK          8             /* clear instruction breakpoint */
  153. #define HW_SETDBREAK            9             /* set data breakpoint (604[E] only) */
  154. #define HW_CLEARDBREAK          10            /* clear data breakpoint (604[E] only) */
  155.  
  156. /* return values of SetHardware */
  157.  
  158. #define HW_AVAILABLE      -1              /* feature available */
  159. #define HW_NOTAVAILABLE    0              /* feature not available */
  160.  
  161. /* return values of GetPPCState */
  162.  
  163. #define PPCSTATEB_POWERSAVE     0              /* PPC is in power save mode */
  164. #define PPCSTATEB_APPACTIVE     1              /* PPC application tasks are active */
  165. #define PPCSTATEB_APPRUNNING    2              /* PPC application task is running */
  166.  
  167. #define PPCSTATEF_POWERSAVE     (1L<<0)
  168. #define PPCSTATEF_APPACTIVE     (1L<<1)
  169. #define PPCSTATEF_APPRUNNING    (1L<<2)
  170.  
  171. /* FP flags (required by ModifyFPExc) */
  172.  
  173. #define FPB_EN_OVERFLOW    0        /* enable overflow exception */
  174. #define FPB_EN_UNDERFLOW   1        /* enable underflow exception */
  175. #define FPB_EN_ZERODIVIDE  2        /* enable zerodivide exception */
  176. #define FPB_EN_INEXACT     3        /* enable inexact op. exception */
  177. #define FPB_EN_INVALID     4        /* enable invalid op. exception */
  178. #define FPB_DIS_OVERFLOW   5        /* disable overflow exception */
  179. #define FPB_DIS_UNDERFLOW  6        /* disable underflow exception */
  180. #define FPB_DIS_ZERODIVIDE 7        /* disable zerodivide exception */
  181. #define FPB_DIS_INEXACT    8        /* disable inexact op. exception */
  182. #define FPB_DIS_INVALID    9        /* disable invalid op. exception */
  183.  
  184. #define FPF_EN_OVERFLOW    (1L<<0)
  185. #define FPF_EN_UNDERFLOW   (1L<<1)
  186. #define FPF_EN_ZERODIVIDE  (1L<<2)
  187. #define FPF_EN_INEXACT     (1L<<3)
  188. #define FPF_EN_INVALID     (1L<<4)
  189. #define FPF_DIS_OVERFLOW   (1L<<5)
  190. #define FPF_DIS_UNDERFLOW  (1L<<6)
  191. #define FPF_DIS_ZERODIVIDE (1L<<7)
  192. #define FPF_DIS_INEXACT    (1L<<8)
  193. #define FPF_DIS_INVALID    (1L<<9)
  194.  
  195. #define FPF_ENABLEALL      $0000001f   /* enable all FP exceptions */
  196. #define FPF_DISABLEALL     $000003e0   /* disable all FP exceptions */
  197.  
  198. /* tags passed to SetExcHandler (exception handler attributes) */
  199.  
  200. #define EXCATTR_TAGS    (TAG_USER+0x101000)
  201. #define EXCATTR_CODE    (EXCATTR_TAGS+0)   /* exception code (required) */
  202. #define EXCATTR_DATA    (EXCATTR_TAGS+1)   /* exception data */
  203. #define EXCATTR_TASK    (EXCATTR_TAGS+2)   /* ppc task address (or NULL) */
  204. #define EXCATTR_EXCID   (EXCATTR_TAGS+3)   /* exception ID */
  205. #define EXCATTR_FLAGS   (EXCATTR_TAGS+4)   /* see below */
  206. #define EXCATTR_NAME    (EXCATTR_TAGS+5)   /* identification name */
  207. #define EXCATTR_PRI     (EXCATTR_TAGS+6)   /* handler priority */
  208.  
  209. /* EXCATTR_FLAGS (either EXC_GLOBAL or EXC_LOCAL, resp. */
  210. /*                EXC_SMALLCONTEXT or EXC_LARGECONTEXT must be */
  211. /*                specified) */
  212.  
  213. #define EXCB_GLOBAL       0        /* global handler */
  214. #define EXCB_LOCAL        1        /* local handler */
  215. #define EXCB_SMALLCONTEXT 2        /* small context structure */
  216. #define EXCB_LARGECONTEXT 3        /* large context structure */
  217. #define EXCB_ACTIVE       4        /* private */
  218.  
  219. #define EXCF_GLOBAL       (1L<<0)
  220. #define EXCF_LOCAL        (1L<<1)
  221. #define EXCF_SMALLCONTEXT (1L<<2)
  222. #define EXCF_LARGECONTEXT (1L<<3)
  223. #define EXCF_ACTIVE       (1L<<4)
  224.  
  225. /* EXCATTR_EXCID (Exception ID) */
  226.  
  227. #define EXCB_MCHECK   2              /* machine check exception */
  228. #define EXCB_DACCESS  3              /* data access exception */
  229. #define EXCB_IACCESS  4              /* instruction access exception */
  230. #define EXCB_INTERRUPT 5             /* external interrupt (V15+) */
  231. #define EXCB_ALIGN    6              /* alignment exception */
  232. #define EXCB_PROGRAM  7              /* program exception */
  233. #define EXCB_FPUN     8              /* FP unavailable exception */
  234. #define EXCB_TRACE    13             /* trace exception */
  235. #define EXCB_PERFMON  15             /* performance monitor exception */
  236. #define EXCB_IABR     19             /* IA breakpoint exception */
  237.  
  238. #define EXCF_MCHECK   (1L<<2)
  239. #define EXCF_DACCESS  (1L<<3)
  240. #define EXCF_IACCESS  (1L<<4)
  241. #define EXCF_INTERRUPT (1L<<5)
  242. #define EXCF_ALIGN    (1L<<6)
  243. #define EXCF_PROGRAM  (1L<<7)
  244. #define EXCF_FPUN     (1L<<8)
  245. #define EXCF_TRACE    (1L<<13)
  246. #define EXCF_PERFMON  (1L<<15)
  247. #define EXCF_IABR     (1L<<19)
  248.  
  249. /* large exception context structure (if EXCATTR_LARGECONTEXT was set) */
  250.  
  251. struct EXCContext {
  252.     ULONG ec_ExcID;       /* exception ID (see above) */
  253.     union {
  254.         ULONG  ec_SRR0;    /* process' program counter */
  255.         APTR   ec_PC;
  256.     } ec_UPC;
  257.     ULONG ec_SRR1;        /* process' context */
  258.     ULONG ec_DAR;         /* DAR register */
  259.     ULONG ec_DSISR;       /* DSISR register */
  260.     ULONG ec_CR;          /* condition code register */
  261.     ULONG ec_CTR;         /* count register */
  262.     ULONG ec_LR;          /* link register */
  263.     ULONG ec_XER;         /* integer exception register */
  264.     ULONG ec_FPSCR;       /* FP status register */
  265.     ULONG ec_GPR[32];     /* r0 - r31 */
  266.     DOUBLE ec_FPR[32];    /* f0 - f31 */
  267. }; /* don't depend on sizeof(EXCContext) */
  268.  
  269. /* small exception context structure (if EXCATTR_SMALLCONTEXT was set) */
  270.  
  271. struct XContext {
  272.     ULONG xco_ExcID;      /* exception ID (see above) */
  273.     ULONG xco_R3;         /* register r3 */
  274. }; /* don't depend on sizeof(XCOSize) */
  275.  
  276. /* return values for exception handlers */
  277.  
  278. #define EXCRETURN_NORMAL 0       /* allow the next exc handlers to complete */
  279. #define EXCRETURN_ABORT  1       /* exception is immediately leaved, all */
  280.                  /* other exception handlers are ignored */
  281.  
  282. #endif /* POWERPCLIB_V7 */
  283.  
  284. #endif
  285.